package rs.pnv.model.response;

import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.NotBlank;

import rs.pnv.model.AbstractEntity;

@Entity
@Table(name = "SEP_PAYMENT_RESPONSE")
@XmlAccessorType(XmlAccessType.FIELD)
public class PaymentResponse extends AbstractEntity {

	@NotBlank
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private Boolean result;

	@NotBlank
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private String merchantId;

	@NotBlank
	@OneToOne
	@JoinColumn(nullable = false)
	@XmlElement(nillable = false)
	private BankAut acquirerAut;

	@NotBlank
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private BigInteger paymentId;

	public PaymentResponse() {

	}

	public Boolean getResult() {
		return result;
	}

	public void setResult(Boolean result) {
		this.result = result;
	}

	public String getMerchantId() {
		return merchantId;
	}

	public void setMerchantId(String merchantId) {
		this.merchantId = merchantId;
	}

	public BankAut getAcquirerAut() {
		return acquirerAut;
	}

	public void setAcquirerAut(BankAut acquirerAut) {
		this.acquirerAut = acquirerAut;
	}

	public BigInteger getPaymentId() {
		return paymentId;
	}

	public void setPaymentId(BigInteger paymentId) {
		this.paymentId = paymentId;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
				.append(result)
				.append(merchantId)
				.append(acquirerAut)
				.append(paymentId)
				.appendSuper(super.hashCode())
				.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}

		final PaymentResponse otherPaymentResponse = (PaymentResponse) obj;

		return new EqualsBuilder()
				.append(result, otherPaymentResponse.getResult())
				.append(merchantId, otherPaymentResponse.getMerchantId())
				.append(acquirerAut, otherPaymentResponse.getAcquirerAut())
				.append(paymentId, otherPaymentResponse.getPaymentId())
				.appendSuper(super.equals(obj))
				.isEquals();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("result", result)
				.append("merchantId", merchantId)
				.append("acquirerAut", acquirerAut)
				.append("paymentId", paymentId)
				.append(super.toString())
				.toString();
	}

}
